TOPDIR := $(shell pwd)


include $(TOPDIR)/TARGET.mk
include $(TOPDIR)/VERSION.mk
-include $(TOPDIR)/EGF_Version.mk
#include $(TOPDIR)/FLAGS.mk
include $(TOPDIR)/LIB.mk


#package debug|release build
BUILD_TARGET ?= Release
#BUILD_TARGET ?= Debug
export BUILD_TARGET

#lib A or SO as part of other application
#BUILD_USE_ENV	:= LIBASO
BUILD_USE_ENV	:= STANDALONE
export BUILD_USE_ENV


CFLAGS += -Wall
CFLAGS += -MD -fPIC
#CFLAGS += -I$(TOPDIR)/ext/include
CFLAGS += -I$(TOPDIR)/common/include
CFLAGS += -I$(TOPDIR)/include

LDFLAGS += -lpthread

CFLAGS += -DXELOG_2_LOCAL=1 -DCONFIG_USE_EXTERNAL_XELOG=1 -DXELOG_PREFIX=\"ISC\"
CFLAGS += -DSQLITE_VER=20200805
ifeq ($(BUILD_TARGET), Release)
CFLAGS +=  -DNDEBUG -DBUILD_TARGET=\"Release\"
#CFLAGS += -g -DBUILD_TARGET=\"Debug\" -DDEBUG=1
else#Debug
CFLAGS += -g -DBUILD_TARGET=\"Debug\" -DDEBUG=1 -funwind-tables -ffunction-sections -rdynamic
endif#Debug

CFLAGS += -D_REENTRANT



ifeq ($(BUILD_MEMWATCH),y)
CFLAGS += -DMEMWATCH 
export BUILD_MEMWATCH
endif

.PHONY: all  base target

all:clean target

base:
	make -C common lib
	make -C ext lib
	
target:base
	make -C platform target

export TARGET_PLATFORM TOPDIR ARCH CC AR CFLAGS LDFLAGS

.PHONY: all clean dist $(LIBNAME)

EGF_Version:
	#svn --username EGF_Version --password EGF_Version_pwd --no-auth-cache export #svn://192.168.168.8/EGF_Version/make/EGF_Version.make EGF_Version.make
	#-make -f EGF_Version.make EGF_Version_mk
clean:
	rm -rf lib/*
	rm -rf release/*
	make -C common clean
	#make -C ext clean
	make -C platform clean
